package com.twb.log.service.impl;

import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import com.twb.core.base.entity.TwbPageInfo;
import com.twb.core.base.service.impl.BaseService;
import com.twb.core.util.ExcelUtils;
import com.twb.core.util.TwbPageUtil;
import com.twb.log.entity.twbLogOperation.TwbLogOperation;
import com.twb.log.entity.twbLogOperation.dto.SearchTwbLogOperationDto;
import com.twb.log.entity.twbLogOperation.vo.SearchTwbLogOperationVo;
import com.twb.log.mapper.TwbLogOperationMapper;
import com.twb.log.service.ITwbLogOperationService;

/**
 * @ClassName twbLogOperationService
 * @Description 日志管理service
 * @author DSY
 * @date 2018年11月3日 下午10:13:20
 */
@Service("twbLogOperationService")
public class TwbLogOperationService extends BaseService<TwbLogOperationMapper,TwbLogOperation> implements ITwbLogOperationService {

	@Autowired
	TwbLogOperationMapper twbLogOperationMapper;

	@Override
	public TwbPageInfo<SearchTwbLogOperationDto> searchTwbLogOperation(SearchTwbLogOperationVo vo) {
		TwbPageUtil.startPage(vo);
		List<SearchTwbLogOperationDto> list = twbLogOperationMapper.searchTwbLogOperation(vo);
		return TwbPageUtil.of(list);
	}

	@Override
	@Async
	public boolean saveBatchTwbLogOperation(List<TwbLogOperation> list) {
		return this.saveBatch(list);
	}

	@Override
	public void exportExcel(SearchTwbLogOperationVo vo, HttpServletResponse response) {
		TwbPageInfo<SearchTwbLogOperationDto> pageInfo = this.searchTwbLogOperation(vo);
		ExcelUtils.exportExcel(vo,vo.getFileName()==null?"操作日志信息":vo.getFileName(), pageInfo.getList(), SearchTwbLogOperationDto.class, response);
	}

}
